Skip to content

Add and improve Numpydoc-style docstrings across core modules#367

Open
lispandfound wants to merge 7 commits intoeven_more_testsfrom
docstrings
Open

Add and improve Numpydoc-style docstrings across core modules#367
lispandfound wants to merge 7 commits intoeven_more_testsfrom
docstrings

Conversation

@lispandfound
Copy link
Contributor

  • Add or enhance Numpydoc-style docstrings for public functions, classes, and methods in qcore modules
  • Improve parameter, returns, raises, examples, and notes sections for clarity and consistency
  • Update XYTSFile and NHMFault class docstrings and attributes for better documentation
  • Refine documentation in constants, coordinates, formats, geo, grid, nhm, point_in_polygon, shared, simulation_structure, siteamp_models, src_site_dist, timeseries, uncertainties/distributions, and xyts modules
  • Add Numpydoc linting GitHub Actions workflow for automated docstring checks

- Add or enhance Numpydoc-style docstrings for public functions, classes, and methods in qcore modules
- Improve parameter, returns, raises, examples, and notes sections for clarity and consistency
- Update XYTSFile and NHMFault class docstrings and attributes for better documentation
- Refine documentation in constants, coordinates, formats, geo, grid, nhm, point_in_polygon, shared, simulation_structure, siteamp_models, src_site_dist, timeseries, uncertainties/distributions, and xyts modules
- Add Numpydoc linting GitHub Actions workflow for automated docstring checks
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @lispandfound, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the documentation of the qcore codebase by standardizing docstrings to the Numpydoc format. This initiative aims to enhance the clarity, consistency, and maintainability of the code, thereby streamlining the onboarding process for new contributors and simplifying code comprehension for all developers. The changes span numerous core modules, ensuring a uniform documentation style throughout critical components. Additionally, an automated linting process is now in place to enforce these new documentation standards.

Highlights

  • Numpydoc Docstring Adoption: Docstrings across various core qcore modules have been added or significantly enhanced to follow the Numpydoc style guide, improving consistency and readability.
  • Docstring Content Improvement: Parameter, returns, raises, examples, and notes sections within docstrings have been refined for greater clarity and detail, making function and class usage easier to understand.
  • Class Documentation Updates: The XYTSFile and NHMFault classes received comprehensive docstring updates, including detailed attribute descriptions, to better document their structure and purpose.
  • Automated Docstring Checks: A new GitHub Actions workflow has been introduced to automatically lint Numpydoc-style docstrings, ensuring future contributions adhere to the established standards.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/numpydoc.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request focuses on adding and improving Numpydoc-style docstrings across various core modules, which significantly enhances code clarity and maintainability. The changes are extensive and well-executed. I've identified a few issues, including a high-severity bug in qcore/constants.py where a function's behavior was altered during refactoring, and a couple of medium-severity issues related to incorrect type hints in qcore/formats.py and qcore/geo.py. My review includes specific suggestions to address these points.

qcore/formats.py Outdated
@@ -49,34 +56,22 @@ def station_file_argparser() -> argparse.ArgumentParser: ... # numpydoc ignore=
def station_file_argparser(
parser: argparse.ArgumentParser | None = None,
) -> argparse.ArgumentParser | None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The function station_file_argparser is type-hinted to return argparse.ArgumentParser | None, but it never returns None. If no parser is provided, a new one is created and returned. The return type hint should be argparse.ArgumentParser.

Suggested change
) -> argparse.ArgumentParser | None:
) -> argparse.ArgumentParser:


def path_from_corners(
corners: list[tuple[float, float]],
output: str | None = "sim.modelpath_hr",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The return type hint list[tuple[float | int, float | int]] | None seems incorrect. The function populates the list with values from ll_mid, which returns a tuple of floats. Therefore, int is not expected in the return type. The type hint should be list[tuple[float, float]] | None.

Suggested change
output: str | None = "sim.modelpath_hr",
) -> list[tuple[float, float]] | None:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant